import { cloneDeep } from 'lodash';
import apiClient from '../apiClient';

class DserDesignService {
  add(params: any) {
    // return this._post('/user_design/add', { ...params });
  }
  del(params: any) {
    // return this._post('/user_design/del', { ...params });
  }
  update(params: any) {
    // return this._post('/user_design/update', { ...params });
  }
  async checkUserDesignByIdContro(params: any) {
    // return this._post('/user_design/checkByIdContro', { ...params });
  }
  getPageContro(params: any) {
    // return this._post('/user_design/getPageContro', { ...params });
  }
  addUserDesignDouble(params: any) {
    // return this._post('/user_design/addUserDesignDouble', { ...params });
  }
  // 获取默认的底版id
  getDefaultDesignId() {
    return apiClient.get({ url: '/common/designer/getDefaultPreProductId' });
  }
  //根据ID获取底版详细数据
  getDesignById(domainId: string) {
    return apiClient.get({ url: '/common/designer/get', params: { domainId } });
  }
  //更具设计id 获取设计数据
  getDesignDataById(domainId: string) {
    return apiClient.get({ url: '/member/product/get', params: { domainId } });
  }
  //保存设计数据为商品
  saveProduct(data: any = {}) {
    const newData = cloneDeep(data);
    newData.designData = JSON.stringify(newData.designData);
    newData.thumbs = JSON.stringify(newData.thumbs);
    newData.previewThumb = JSON.stringify(newData.previewThumb);
    return apiClient.post({ url: '/member/product/saveDesign', data: newData });
  }

  // 查询ai使用剩余次数
  async queryUseCountResult(type: "kouTu" | "dongMa" | "tuYa" | "xuanRan" = "kouTu") {
    const res = await apiClient.get({
      url: '/member/member-use-count/queryUseCountResult',
      params: {
        type
      }
    });
    return res;
  }
}
const userDesignService = new DserDesignService();

export default userDesignService;
